package org.qqcui.designpattern.patterns.decorator;

import org.qqcui.designpattern.patterns.decorator.component.Drink;
import org.qqcui.designpattern.patterns.decorator.component.Espresso;
import org.qqcui.designpattern.patterns.decorator.decorator.Chocolate;
import org.qqcui.designpattern.patterns.decorator.decorator.Milk;

/**
 * 咖啡店客户都安
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/4/29 10:55
 **/
public class CoffeeBar {

    public static void main(String[] args) {
        // 先点意大利咖啡
        Drink drink = new Espresso();
        System.out.println("单品：" + drink.getDesc() + "，价格：" + drink.cost());

        // 加份巧克力
        drink = new Chocolate(drink);
        System.out.println("加一份巧克力后：" + drink.getDesc() + "，价格：" + drink.cost());

        // 加一份牛奶
        drink = new Milk(drink);
        System.out.println("加一份牛奶+巧克力后：" + drink.getDesc() + "，价格：" + drink.cost());

        // 再加一份巧克力
        drink = new Chocolate(drink);
        System.out.println("加一份牛奶+2份巧克力后：" + drink.getDesc() + "，价格：" + drink.cost());
    }
}
